import http from '../../utils/http.js'


export function getUserInfo(){
	return new Promise((resolve,reject)=>{
		var params={
		   url:'/v1/app/member/info',
		   method:'GET',
		   data:{},
		   callBack:(res)=>{
			if(res.code==0){
			 resolve(res)
			}
			else{
			 reject(res.msg)
			}
		}
	  }
	  http.request(params)
	})
}

export function login(phone,code,merchant){
	return new Promise((resolve,reject)=>{
		var params={
		   url:'/v1/app/member/login',
		   method:'POST',
		   data:{
			   mobile: phone,
			   code: code,
			   merchant: merchant
		   },
		   callBack:(res)=>{
			if(res.code==0){
			 resolve(res)
			}
			else{
			 reject(res.msg)
			}
		}
	  }
	  http.request(params)
	})
} 

export function aliLogin(phone,code,merchant){
	return new Promise((resolve,reject)=>{
		var params={
		   url:'/v1/app/member/alipay/onekey/login',
		   method:'POST',
		   data:{
			   mobile: phone,
			   code: code,
			   merchant: merchant
		   },
		   callBack:(res)=>{
			if(res.code==0){
			 resolve(res)
			}
			else{
			 reject(res.msg)
			}
		}
	  }
	  http.request(params)
	})
} 